<?
// Database Connection
$dbname = 'tcntrans_main';
$dbhost = 'localhost';
$dbuser = 'tcntrans';
$dbpass = 'hJV65VUX';
$db = mysql_connect($dbhost,$dbuser,$dbpass);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title>New document</title>
<meta name="generator" content="TSW WebCoder">
</head>

<body>
<h1>Add Main Cat Column to transLinkPath</h1>
<?
$sql1 = "SELECT * from transLevels";
$result1 = mysql_db_query($dbname,$sql1); 

while ($value1 = mysql_fetch_assoc($result1)) {
	$path = $value1[Path];
	$levelID = $value1[LevelID];
	
	echo $path.' '.$levelID;
	
	// Get first 2 characters of $path
	$newPath = substr($path,0,2);
	
	echo ' '.$newPath.'<br>';
	
	$sql2 = "UPDATE transLinkPath SET MainPath = '$newPath' WHERE PathID = '$levelID'";
	echo $sql2.'<br>';
	$result2 = mysql_db_query($dbname,$sql2);		
}
?>
</body>
</html>